<% 
#locals
blog=blog_single 

blog.view_count=blog.view_count.to_i+1
blog.save
@blog=Blog.find(blog.blog_id)

begin
tag = Topic.find(blog.topic_id)
rescue
end

tagname=tag.name unless tag.nil?

%>

      <table class="ContentBlock" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td align="left" valign="top">
          <a href="/?blog=<%= blog.id %>&cat=<%= params[:cat] %>">
          	<% unless blog.media_url.blank? %>
	<img alt="" title="" border="0"  src="<%=h blog.media_url%>">
	<% end %>
          </a><a class="ContentLable" href='/?tag=<%= blog.topic_id %>&cat=<%= params[:cat] %>'> <%=h tagname %></a>
              <h3><a href="/?blog=<%= blog.id %>&cat=<%= params[:cat] %>" class="ContentTitle"><%= sanitize textilize(blog.title) %></a></h3>

          <p>	  <%= display blog.body%></p></td>
          <td width="300" align="left" valign="top"><dl>
            <dt>Posted <%= time_ago_in_words blog.created_at  %></dt>
            <dt>By <a href="#" class="blue"><%= @blog.person.name %></a></dt>

            <dt><a href="/?blog=<%= blog.id %>&cat=<%= params[:cat] %>" class="blue"><%= blog.view_count %></a> views, <a href="/?blog=<%= blog.id %>&cat=<%= params[:cat] %>#comments" class="blue"><%= "#{ blog.comments.count}" %></a> Comments</dt>
    <%- if current_person?(@blog.person) -%>
      | <%= link_to "Edit", edit_blog_post_path(@blog, blog) %>
      | <%= link_to "Delete", blog_post_path(@blog, blog),
                              :method => :delete %>
    <%- end -%>
                <dt><a href="#" class="Pink">how about shaving his ass with a rusty rusor?</a></dt>
          </dl></td>
        </tr>
      </table>
<a href='comments'></a>
  <%- unless blog.comments.empty? -%>
  <h4 id="comments">Comments</h4>
    <ul class="list comments full">
      <%= render :partial => 'posts/comment', :collection => blog.comments %>
    </ul>
  <%- end -%>
  <%- if logged_in? -%>
    <h4>Leave a comment</h4>

    <% form_for :comment, :url => blog_post_comments_path(@blog, blog),
                          :html => { :id => "blogcomment" } do |f| %>
      <div class="form_row">
        <%= f.text_area :body, :rows => 10 %>
      </div>
  
      <div class="form_row">
        <%= submit_tag "Submit", :class => "button" %>
      </div>
    <% end %>

  <%- end -%>
